package com.agileboot.domain.airport.inspection.model;

import cn.hutool.core.bean.BeanUtil;
import com.agileboot.domain.airport.inspection.command.AddSirInspectionCommand;
import com.agileboot.domain.airport.inspection.command.UpdateSirInspectionCommand;
import com.agileboot.domain.airport.inspection.db.SirInspectionEntity;
import com.agileboot.domain.airport.inspection.db.SirInspectionService;
import lombok.NoArgsConstructor;

/**
 * @author valarchie
 */
@NoArgsConstructor
public class SirInspectionModel extends SirInspectionEntity {

    private SirInspectionService inspectionService;

    public SirInspectionModel(SirInspectionService inspectionService) {
        this.inspectionService = inspectionService;
    }

    public SirInspectionModel(SirInspectionEntity entity, SirInspectionService inspectionService) {
        if (entity != null) {
            BeanUtil.copyProperties(entity, this);
        }
        this.inspectionService = inspectionService;
    }

    public void loadFromAddCommand(AddSirInspectionCommand addCommand) {
        if (addCommand != null) {
            BeanUtil.copyProperties(addCommand, this, "inspectionId");
        }
    }

    public void loadFromUpdateCommand(UpdateSirInspectionCommand command) {
        if (command != null) {
            loadFromAddCommand(command);
        }
    }

}